<template>
  <div class="app-container">
    <!-- 搜索栏 -->
    <el-form :model="queryParams" ref="queryForm" :inline="true" class="hear-ss">
      <el-form-item label="姓名：" prop="violativeName">
        <el-input v-model="queryParams.violativeName" placeholder="请输入姓名" clearable></el-input>
      </el-form-item>
      <el-form-item label="班级：" prop="violativeClass">
        <el-input v-model="queryParams.violativeClass" placeholder="请输入班级" clearable></el-input>
      </el-form-item>
      <el-form-item label="违规级别：" prop="violativeLevel" label-width="110px">
        <el-select v-model="queryParams.violativeLevel" clearable placeholder="请选择">
          <el-option
            v-for="item in gradeOptions"
            :label="item.dictLabel"
            :value="item.dictValue"
            :key="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="search" icon="el-icon-search" size="small">搜索</el-button>
        <el-button @click="reset" icon="el-icon-refresh" size="small">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 添加按钮 -->
    <div style="margin: 20px 0px 8px 0px"></div>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" @click="addWeiji" icon="el-icon-plus" size="small">新增违纪信息</el-button>
      </el-col>
      <el-col :span="1.5" v-hasPermi="['violative:apply:process']">
        <el-button
          type="warning"
          icon="el-icon-circle-check"
          size="small"
          @click="handledApproval"
          :disabled="multiple"
        >审批通报</el-button>
      </el-col>
    </el-row>
    <!-- 表单 -->
    <el-table v-loading="loading" :data="form" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column prop="violativeName" label="姓名" align="center"></el-table-column>
      <el-table-column prop="violativeClassName" label="班级" align="center"></el-table-column>
      <el-table-column prop="classTeacherId" label="班主任" align="center"></el-table-column>
      <el-table-column prop="applyStatus" label="处理状态" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.applyStatus==0">草稿</span>
          <span v-if="scope.row.applyStatus==1">处理中</span>
          <span v-if="scope.row.applyStatus==2">已通报</span>
          <span v-if="scope.row.applyStatus==3">不用通报</span>
        </template>
      </el-table-column>
      <el-table-column prop="violativeLevel" label="违纪级别" align="center">
        <template slot-scope="scope">{{getDictLabel(gradeOptions,scope.row.violativeLevel)}}</template>
      </el-table-column>
      <el-table-column prop="description" label="描述" align="center"></el-table-column>
      <el-table-column prop="createTime" label="违纪时间" :show-overflow-tooltip="true" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.createTime!= null">{{ parseTime(scope.row.createTime ) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-tooltip content="修改违纪" placement="top">
            <el-button
              v-if="scope.row.applyStatus==1"
              size="mini"
              type="success"
              icon="el-icon-edit"
              circle
              @click="handleEdit(scope.row)"
            ></el-button>
          </el-tooltip>
          <el-tooltip content="查看详情" placement="top" v-if="scope.row.applyStatus>1">
            <el-button size="mini" icon="el-icon-search" circle @click="handleView(scope.row)"></el-button>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <div>
      <el-pagination
        class="page"
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryParams.pageNum"
        :page-sizes="[10, 20, 40, 60]"
        :page-size="queryParams.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
    <!-- 添加违纪弹框 -->
    <el-dialog title="创建违纪" :visible.sync="dialogVisible" width="60%" :before-close="cancelRule">
      <el-form :model="form1" :rules="rules" ref="form1" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="班级：" prop="violativeClass">
              <el-select
                v-model="form1.violativeClass"
                style="width:60%"
                clearable
                @change="getStudentList"
                :disabled="isView"
              >
                <el-option
                  v-for="item in classList"
                  :key="item.id"
                  :label="item.className"
                  :value="item.id+''"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="姓名：" prop="studentId">
              <el-select
                v-model="form1.studentId"
                style="width:60%"
                clearable
                filterable
                placeholder="请选择姓名"
                :disabled="isView"
              >
                <el-option
                  v-for="item in studentList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id+''"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="违纪级别：" prop="violativeLevel">
              <el-select
                style="width:60%"
                v-model="form1.violativeLevel"
                clearable
                placeholder="请选择"
                :disabled="isView"
              >
                <el-option
                  v-for="item in gradeOptions"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                  :key="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="违纪时间：" prop="violativeTime">
              <el-date-picker
                style="width:60%"
                :disabled="isView"
                v-model="form1.violativeTime"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="datetime"
                placeholder="选择日期时间"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="标签：" prop="violative">
          <el-checkbox-group v-model="violative" :disabled="isView">
            <el-checkbox
              v-for="item in statusOptions"
              :label="item.dictValue"
              :key="item.id"
            >{{item.dictLabel}}</el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="描述：" prop="description">
          <el-input
            type="textarea"
            style="width: 89%;"
            :autosize="{ minRows: 3, maxRows: 6 }"
            :disabled="isView"
            placeholder="请输入内容"
            v-model="form1.description"
          ></el-input>
        </el-form-item>
        <el-form-item label="违纪图片:" prop="fileList">
          <el-upload
            v-if="!isView"
            :action="upload.url"
            list-type="picture-card"
            :headers="headers"
            :on-success="onSuccess"
            :on-remove="handleRemove"
            :on-exceed="handleExceed"
            :file-list="fileList"
            multiple
            :limit="3"
            :before-upload="onBeforeImgUpload"
          >
            <i class="el-icon-plus"></i>
          </el-upload>
          <div v-else>
            <el-image
              v-for="item in fileList"
              style="width: 100px; height: 100px;margin-right: 10px;"
              :key="item.url"
              :src="item.url"
              :preview-src-list="[item.url]"
            ></el-image>
          </div>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer" v-if="!isView">
        <el-button @click="cancelRule">取 消</el-button>
        <el-button type="primary" @click="addRule()">提 交</el-button>
      </span>
    </el-dialog>

    <el-dialog
      title="审批违纪"
      :visible.sync="dialogApprovalVisible"
      width="60%"
      :before-close="cancelApproved"
    >
      <el-form :model="approvalForm" :rules="approvalRules" ref="approvalForm" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="审批状态" prop="applyStatus">
              <el-radio label="2" v-model="approvalForm.applyStatus">审批通报</el-radio>
              <el-radio label="3" v-model="approvalForm.applyStatus">审批不通报</el-radio>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="通报学员">{{weijiName}}</el-form-item>
          </el-col>
        </el-row>

        <div v-if="approvalForm.applyStatus==2">
          <el-row>
            <el-col :span="12">
              <el-form-item label="标题" prop="title">
                <el-input v-model="approvalForm.title" style="width:80%"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="通知类型">
                <el-select v-model="approvalForm.noticeType" :disabled="true">
                  <!-- <el-option label="学工通知" value="0"></el-option> -->
                  <el-option label="违纪通知" value="2"></el-option>
                  <!-- <el-option label="安全通知" value="1"></el-option> -->
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="发布范围" prop="releaseScopeNotice">
                <el-select v-model="approvalForm.releaseScopeNotice" @change="selectScope">
                  <el-option label="班级" value="1"></el-option>
                  <el-option label="年级" value="2"></el-option>
                  <el-option label="全校" value="3"></el-option>
                </el-select>
                <!--班级-->
                <el-select
                  v-if="approvalForm.releaseScopeNotice==1"
                  multiple
                  collapse-tags
                  v-model="approvalForm.classIds"
                  placeholder="输入班级"
                  clearable
                >
                  <el-option
                    v-for="item in classAllList"
                    :label="item.className"
                    :value="item.id+''"
                    :key="item.id"
                  ></el-option>
                </el-select>
                <!--年级-->
                <el-select v-if="approvalForm.releaseScopeNotice==2" v-model="approvalForm.grade">
                  <el-option
                    v-for="item in gradeList"
                    :key="item.id"
                    :label="item.dictLabel+''"
                    :value="item.dictValue+''"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否通知学生">
                <el-radio v-model="approvalForm.isNoticeStudent" label="1">是</el-radio>
                <el-radio v-model="approvalForm.isNoticeStudent" label="0">否</el-radio>
              </el-form-item>
            </el-col>
          </el-row>
          <!-- <el-row>
                <el-col :span="12">
                    <el-form-item label="是否立即发送" prop="isSend">
                        <el-radio v-model="approvalForm.isSend" label="1">是</el-radio>
                        <el-radio v-model="approvalForm.isSend" label="0">否</el-radio>
                    </el-form-item>
                </el-col>
          </el-row>-->
          <el-form-item label="通报内容" prop="noticeContent">
            <quill-editor
              v-model="approvalForm.noticeContent"
              ref="myQuillEditor"
              :options="editorOption"
            ></quill-editor>
          </el-form-item>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancelApproved">取 消</el-button>
        <el-button type="primary" @click="submitApproval()">提 交</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';
import {
  weijiList,
  weijiAdd,
  weijiDetails,
  weijiCancel,
  historyWorkFlowList,
  findClassAll,
  findStudentByClassId,
  violativeProcess
} from "@/api/workflow/weiji";
import { getToken } from "@/utils/auth";
import { quillEditor } from "vue-quill-editor";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import { findAllSchoolClass } from "@/api/studentInfo/infoMaintenance/index";

export default {
  // import引入的组件需要注入到对象中才能使用
  components: {
    quillEditor
  },
  data() {
    var validatePass = (rule, value, callback) => {
      debugger;
      if (
        this.approvalForm.releaseScopeNotice == 1 &&
        (!this.approvalForm.classIds || this.approvalForm.classIds.length < 1)
      ) {
        callback(new Error("请选择班级"));
      }
      if (
        this.approvalForm.releaseScopeNotice == 2 &&
        !this.approvalForm.grade
      ) {
        callback(new Error("请选择年级"));
      } else {
        // this.$refs['leaveFormData'].clearValidate(['leaveStartTime','leaveEndTime'])
        callback();
      }
    };
    // 这里存放数据
    return {
      upload: {
        url: process.env.VUE_APP_BASE_API + "/test/uploadImage",
        showUrl: process.env.VUE_APP_BASE_API + "/school/file/"
      },
      // 编辑器配置
      editorOption: {
        placeholder: "在这里输入内容",
        modules: {
          toolbar: [
            ["bold", "italic", "underline", "strike"], //  加粗、倾斜、下划线、删除线
            ["blockquote", "code-block"], // 引用代码块
            [{ header: 1 }, { header: 2 }], // 标题，键值对应的形式，1，2 表示字体大小
            [{ list: "ordered" }, { list: "bullet" }], // 列表
            [{ script: "sub" }, { script: "super" }], // 上下标
            [{ indent: -1 }, { indent: +1 }], // 缩进
            [{ direction: "rtl" }], // 文本方向
            [{ size: ["small", false, "large", "huge"] }], // 字体大小
            [{ header: [1, 2, 3, 4, 5, 6, false] }], // 几级标题
            [{ color: [] }, { background: [] }], // 字体颜色，字体背景颜色
            [{ font: [] }], // 字体
            [{ align: [] }], // 对齐方式
            ["clean"], //清除
            ["image", "video"] // 上传图片、上传视频
          ]
        }
      },
      dialogApprovalVisible: false,
      multiple: true,
      isView: false,
      //审批记录
      activities: [],
      // 遮罩层
      loading: false,
      //弹框
      dialogVisible: false,
      dialogVisible1: false,
      // 分页总页数
      total: 0,
      //查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10
      },
      // 状态数据字典
      statusOptions: [],
      gradeOptions: [],
      //添加违规参数
      form1: {
        violativeClass: "",
        violativeLevel: "",
        violativeName: "",
        violativeTag: "",
        description: "",
        fileName: "",
        filePath: "",
        applyStatus: "1"
      },
      form2: {},
      data: {
        applyDesc: "",
        applyID: "",
        applyTitle: "",
        approvedBy: "",
        attachment: "",
        businessKey: "",
        currNode: "",
        flag: 0,
        lastNode: "",
        processInstanceId: "",
        taskId: "",
        variables: {}
      },
      //多选绑定数组
      violative: [],
      //表单绑定对象
      form: [],
      //表单验证
      rules: {
        studentId: [
          { required: true, message: "请输入学生姓名", trigger: "blur" }
        ],
        violativeClass: [
          { required: true, message: "请输入学生班级", trigger: "blur" }
        ],
        violativeLevel: [
          { required: true, message: "请选择违规级别：", trigger: "change" }
        ],
        violativeTime: [
          { required: true, message: "请选择违规时间：", trigger: "change" }
        ]
      },
      approvalRules: {
        applyStatus: [
          { required: true, message: "请选择审批状态", trigger: "blur" }
        ],
        title: [{ required: true, message: "请填写标题", trigger: "blur" }],
        releaseScopeNotice: [
          { required: true, message: "请选择发布范围", trigger: "blur" },
          { validator: validatePass, trigger: "blur" }
        ],
        noticeContent: [
          { required: true, message: "请编辑迎新内容", trigger: "blur" }
        ]
      },
      //文件上传数组
      fileList: [],
      fileList1: [],
      name: [],
      url: [],
      arr: [],
      classList: [],
      studentList: [],
      rowList: [],
      approvalForm: {},
      gradeList: [],
      classAllList: [],
      weijiName: null
    };
  },
  // 监听属性 类似于data概念
  computed: {
    headers() {
      return {
        Authorization: getToken()
      };
    }
  },
  // 监控data中的数据变化
  watch: {},
  // 方法集合
  methods: {
    onBeforeImgUpload(file) {
      // 判断是否符合文件大小的限制需求
      const isLt2M = file.size / 1024 / 1024 < 2;
      // 判断是否符合文件类型需求
      if (!isLt2M) {
        this.$message({
          message: `上传文件大小不能超过2M!`,
          type: "warning"
        });
      }
      return isLt2M;
    },
    selectScope(val) {
      if (val == 1) {
        //查询有效的班级
        this.getClassList();
      }
      if (val == 2) {
        //查询有效的班级
        this.getDicts("class_grade").then(response => {
          this.gradeList = response.data;
        });
      }
    },
    getClassList() {
      findAllSchoolClass().then(resp => {
        this.classAllList = resp.data;
      });
    },
    handleSelectionChange(selection) {
      console.log(selection);
      this.rowList = selection;
      this.multiple = !selection.length;
    },
    getDictLabel(list, value) {
      for (let i = 0; i < list.length; i++) {
        if (list[i].dictValue == value) {
          return list[i].dictLabel;
        }
      }
    },
    getStudentName(id) {
      console.log("id", id);
      for (let i = 0; i < this.studentList.length; i++) {
        if (this.studentList[i].id == id) {
          return this.studentList[i].name;
        }
      }
    },
    getClassTeacher(classId) {
      console.log("id", classId);
      for (let i = 0; i < this.classList.length; i++) {
        if (this.classList[i].id == classId) {
          return this.classList[i].classTeacherId;
        }
      }
    },
    getClassName(classId) {
      console.log("id", classId);
      for (let i = 0; i < this.classList.length; i++) {
        if (this.classList[i].id == classId) {
          return this.classList[i].className;
        }
      }
    },
    getStudentList(val) {
      findStudentByClassId(val).then(resp => {
        this.studentList = resp.data;
      });
    },
    getClassAll() {
      findClassAll({}).then(resp => {
        this.classList = resp.data;
      });
    },
    //违纪查询
    getList() {
      this.loading = true;
      weijiList(this.queryParams).then(res => {
        this.form = res.data.list;
        this.total = res.data.total;
        this.loading = false;
      });
    },
    //搜索按钮操作
    search() {
      this.getList();
    },
    //重置按钮操作
    reset() {
      this.fileList = undefined;
      this.resetForm("queryForm");
      this.search();
    },
    cancelApproved() {
      this.violative = [];
      this.fileList = [];
      this.resetForm("approvalForm");
      this.dialogApprovalVisible = false;
    },
    //添加违纪取消按钮
    cancelRule() {
      this.violative = [];
      this.fileList = [];
      this.resetForm("queryForm1");
      this.dialogVisible = false;
    },
    //添加违纪打开按钮
    addWeiji() {
      this.dialogVisible = true;
      this.isView = false;
      this.violative = [];
      this.fileList = [];
      this.form1 = {};
      this.resetForm("form1");
    },
    //添加违纪提交按钮
    addRule() {
      this.$refs.form1.validate(valid => {
        if (valid) {
          let filePath = [];
          for (let i = 0; i < this.fileList.length; i++) {
            filePath.push(this.fileList[i].dataUrl);
          }
          this.form1.filePath = filePath.join(",");
          this.form1.violativeTag = this.violative.join(",");
          this.form1.violativeName = this.getStudentName(this.form1.studentId);
          this.form1.classTeacherId = this.getClassTeacher(
            this.form1.violativeClass
          );
          this.form1.violativeClassName = this.getClassName(
            this.form1.violativeClass
          );
          weijiAdd(this.form1).then(res => {
            this.$message({
              message: "添加成功",
              type: "success"
            });
            this.dialogVisible = false;
            this.getList();
          });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    //上传
    handleRemove(file, fileList) {
      this.fileList = fileList;
      console.log("remove", fileList);
    },
    handlePreview(file) {
      console.log(file, 231213);
    },
    handleExceed(files, fileList) {
      this.$message.warning("最多能上传 3 个文件文件");
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    onSuccess(response, file, fileList) {
      this.getFileList(fileList);
      console.log("onSuccess", fileList);
    },
    getFileList(allFileList) {
      if (!allFileList) {
        return;
      }
      for (let i = 0; i < allFileList.length; i++) {
        if (allFileList[i].response) {
          this.fileList.push({
            name: allFileList[i].name,
            url: this.upload.showUrl + allFileList[i].response.result,
            dataUrl: allFileList[i].response.result
          });
        }
      }
    },
    handleEdit(row) {
      this.dialogVisible = true;

      this.form1 = row;
      this.getStudentList(row.violativeClass);
      if (this.form1.violativeTag) {
        this.violative = this.form1.violativeTag.split(",");
      }
      if (this.form1.filePath) {
        this.fileList = [];
        const files = this.form1.filePath.split(",");
        for (let i = 0; i < files.length; i++) {
          this.fileList.push({
            name: files[i],
            url: this.upload.showUrl + files[i],
            dataUrl: files[i]
          });
        }
      }
    },
    handleView(row) {
      this.isView = true;
      this.handleEdit(row);
    },
    handledApproval() {
      this.rowList;
      let ids = [];
      let names = [];
      for (let i = 0; i < this.rowList.length; i++) {
        ids[i] = this.rowList[i].id;
        names[i] = this.rowList[i].violativeName;
      }
      this.approvalForm.ids = ids.join(",");
      this.weijiName = names.join(",");
      this.approvalForm.noticeType = "2";
      this.dialogApprovalVisible = true;
    },
    submitApproval() {
      //提交违纪审批

      this.$refs.approvalForm.validate(valid => {
        if (valid) {
          violativeProcess(this.approvalForm).then(resp => {
            this.$message({
              message: "提交成功",
              type: "success"
            });
            this.dialogApprovalVisible = false;
            this.getList();
          });
        }
      });
    },
    //分页
    handleSizeChange(num) {
      this.queryParams.pageSize = num;
      this.getList();
    },
    handleCurrentChange(num) {
      this.queryParams.pageNum = num;
      this.getList();
    },
    //撤销违规申请按钮
    cancel(row) {
      this.$confirm("此操作将永久撤销该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.loading = true;
          this.data.processInstanceId = row.processId;
          weijiCancel(this.data).then(res => {
            console.log(res, 88888);
            this.$message({
              message: "撤销成功",
              type: "success"
            });
            this.getList();
            this.loading = false;
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消撤销"
          });
        });
    },
    //违规详情查看按钮
    details(row) {
      this.dialogVisible1 = true;
      const processInstanceId = row.processId;
      weijiDetails(processInstanceId).then(res => {
        this.form2 = res.data;
        this.arr = res.data.violativeTag.split(",");
        let filenameList = res.data.fileName.split(",");
        let filePathList = res.data.filePath.split(",");
        this.fileList1 = [];
        for (let i = 0; i < filenameList.length; i++) {
          if (filenameList[i] == "") return;
          let fileJson = { name: filenameList[i], url: filePathList[i] };
          this.fileList1.push(fileJson);
        }
      });
      this.historyWorkFlowList(row);
    },
    //查询审批历史记录
    historyWorkFlowList(row) {
      const processInstanceId = row.processId;
      historyWorkFlowList({ processInstanceId: processInstanceId }).then(
        resp => {
          console.log(resp);
          this.activities = resp.data;
        }
      );
    },
    handleClose() {
      this.dialogVisible1 = false;
      this.dialogVisible2 = false;
    },
    //预览图片
    handlePreview1(val) {
      console.log(val, 585);
      if (val) {
        const image = new Image();
        image.src = process.env.VUE_APP_BASE_API + "/school/file/" + val.url;
        const imgWindow = window.open(val);
        imgWindow.document.write(image.outerHTML);
      }
    },
    handleChange() {}
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {
    this.getList();
    this.getDicts("VIOLATIVE_TAG").then(response => {
      this.statusOptions = response.data;
    });
    this.getDicts("violative_level").then(response => {
      this.gradeOptions = response.data;
      console.log(this.gradeOptions, 565);
    });
    this.getClassAll();
  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {} // 如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='scss' scoped>
.page {
  float: right;
  margin: 10px 0px 0px 150px;
  padding-right: 80px;
}
</style>